<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>模块管理</title>

    <link href="/after/css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="/after/css/font-awesome.min.css?v=4.3.0" rel="stylesheet">

    <!-- Data Tables -->
    <link href="/after/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">

    <link href="/after/css/animate.min.css" rel="stylesheet">
    <link href="/after/css/style.min.css?v=3.0.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>内容维护 <small>自定义模块使用</small></h5>
                </div>
                <div class="ibox-content">

                    <table class="table table-striped table-bordered table-hover dataTables-example">
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>标题</th>
                            <th>所属栏目</th>
                            <th>发布时间</th>
                            <th>所用模型</th>
                            <th>链接方式</th>
                            <th>使用状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#setting date_format="yyyy-MM-dd hh:mm:ss">
                        <#list page as mod>
                        <tr>
                            <td>${mod_index+1}</td>
                            <td>${mod.title}</td>
                            <td>${mod.belongTo}</td>
                            <td>${mod.createTime?date}</td>
                            <td>${mod.model}</td>
                            <td>
                                <#if mod.target=='_self'>
                                    当前窗口
                                </#if>
                                <#if mod.target=='_blank'>
                                    新标签页
                                </#if>
                                <#if mod.target=='_parent'>
                                    父窗口
                                </#if>
                                <#if mod.target=='_top'>
                                    最外层窗口
                                </#if>
                            </td>
                            <td>
                                <#if mod.status==0>
                                    可使用||<a href="javascript:badModule(${mod.moduleId})">禁用</a>
                                </#if>
                                <#if mod.status==1>
                                    <a href="javascript:useModule(${mod.moduleId})">使用</a>||已禁用
                                </#if>
                            </td>
                            <td><a href="javascript:delModule(${mod.moduleId})">删除</a>||<a href="javascript:modModule(${mod.moduleId})">编辑</a></td>
                        </tr>
                        </#list>
                        </tfoot>
                    </table>

                </div>
            </div>
        </div>
    </div>
    </div>

<!-- 全局js -->
<script src="/after/js/jquery-2.1.1.min.js"></script>
<script src="/after/js/bootstrap.min.js?v=3.4.0"></script>



<script src="/after/js/plugins/jeditable/jquery.jeditable.js"></script>

<!-- Data Tables -->
<script src="/after/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="/after/js/plugins/dataTables/dataTables.js"></script>

<!-- 自定义js -->
<script src="/after/js/content.min.js?v=1.0.0"></script>
<script src="/after/js/layer/layer.js"></script>

<!-- Page-Level Scripts -->
<script>
    $(document).ready(function(){$(".dataTables-example").dataTable();var a=$("#editable").dataTable();a.$("td").editable("../example_ajax.php",{"callback":function(d,c){var b=a.fnGetPosition(this);a.fnUpdate(d,b[0],b[1])},"submitdata":function(c,b){return{"row_id":this.parentNode.getAttribute("id"),"column":a.fnGetPosition(this)[2]}},"width":"90%","height":"100%"})});function fnClickAddRow(){$("#editable").dataTable().fnAddData(["Custom row","New row","New row","New row","New row"])};
</script>
<script>
    //删除模块
    var delModule = function(id){
        if(confirm('删除后不可恢复，请确认')){
            $.ajax({
                type:'GET',
                dataType:'json',
                url:'/test/delModule.do',
                data:{
                    id:id
                },success:function(msg){
                    location.reload();
                },error:function(){
                    console.log("删除错误！");
                }
            })
        }
    }
    //更新模块
    var modModule = function(id){
        layer.open({
            type:2,
            title:'填写退货信息',
            fix:'false',
            maxmin:true,
            shadeClose:true,
            area:['400px','600px'],
            content:'/test/queryOneModule.do?id='+id,
            end:function(){
                location.reload();
            }
        })
    }
    //使用当前模块
    var useModule = function(id){
        $.ajax({
            type:'GET',
            dataType:'json',
            url:'/test/useModule.do',
            data:{
                id:id
            },success:function(msg){
                location.reload();
            },error:function(){
                console.log("删除错误！");
            }
        })
    }
    //禁用当前模块
    var badModule = function(id){
        $.ajax({
            type:'GET',
            dataType:'json',
            url:'/test/badModule.do',
            data:{
                id:id
            },success:function(msg){
                location.reload();
            },error:function(){
                console.log("删除错误！");
            }
        })
    }
</script>
</body>

</html>